<%@ page language="java" import="java.util.*" import="java.sql.*"  pageEncoding="utf-8" import="java.util.Date" import="java.text.SimpleDateFormat"%>
<html>
 <body>
 <%@ include file="dengluPublic.jsp" %>
 <%!String id; 
 String zhuangtai;
 String zhuangtai1="借出";
 String zhuangtai2="未借出";
 int jcishu;
  %> 
    <%
    request.setCharacterEncoding("utf-8");
    id=request.getParameter("id");            
     %>
     <%
     Date time=new Date();
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
    String newtime=sdf.format(time);
        
     String driverClass1="com.mysql.jdbc.Driver";
	    String url1="jdbc:mysql://localhost:3306/vote?useSSL=false";
	    String user1="root";
	    String password1="womenilu2580";	
		    	    
	    Class.forName(driverClass1);
	    Connection conn1=DriverManager.getConnection(url1,user1,password1);	 
	    Statement stat1=conn1.createStatement();
	    String sql1="select zhuangtai,jcishu from science where id='"+id+"'";
	    ResultSet rs1=stat1.executeQuery(sql1);
	    while(rs1.next())
	    {
	    	zhuangtai=rs1.getString("zhuangtai");
	    	jcishu=Integer.valueOf(rs1.getString("jcishu"));
	    	
	    }
	    	        	    
	    Class.forName(driverClass1);
	    Connection conn=DriverManager.getConnection(url1,user1,password1);	 
	    Statement stat=conn.createStatement();
	    if(zhuangtai.equals("借出"))
	    {
	    String sql="update science set zhuangtai='"+zhuangtai2+"',jname='null',jtime='null' where id='"+id+"'";
	    stat.executeUpdate(sql); 
	    }else
	    {
	    jcishu=jcishu+1;
	    String sql="update science set zhuangtai='"+zhuangtai1+"',jname='"+customer.getCname()+"',jtime='"+newtime+"',jcishu="+jcishu+" where id='"+id+"'";
	    stat.executeUpdate(sql);
	    }
	    
	   %> 
	   
   <jsp:forward page="scienceNews.jsp?id=<%=id %>"></jsp:forward>
    
  </body>
</html>
